package cn.com.sbell.vss.ems.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.com.sbell.vss.BaseDao;
import cn.com.sbell.vss.ems.dao.ILogDao;
import cn.com.sbell.vss.ems.entity.Log;

/**
 * @author Yifu.HUANG
 */
public class LogDaoImpl extends BaseDao implements ILogDao {

	public String insert(Log alog) {
		alog.setId(generateRandomGUID());
                String ips = alog.getInputParameters();
                if(ips!=null && 512 <= ips.length()){
                    alog.setInputParameters(ips.substring(0,512));
                }                
		this.getSqlMapClientTemplate().insert("insertLog", alog);
		return alog.getId();
	}

	public void update(Log alog) {
		this.getSqlMapClientTemplate().update("updateLog", alog);
	}

	public void delete(Map param) {
		this.getSqlMapClientTemplate().delete("deleteLog", param);
	}

	public void delete(String id) {
		Map param = new HashMap();
		param.put("id", id);
		this.delete(param);
	}

	public List find(Map param) {
		return this.getSqlMapClientTemplate().queryForList("findLog", param);
	}

}
